from func import screenShot, bdOCR
from utils import WoxEx
import json
import os


class Main(WoxEx):
    def query(self, keyword):
        results = [{
            "Title": "Press \'ENTER\'",
            "SubTitle": 'default: low accuracy; \'1\': high accuracy',
            "IcoPath": "Images/ico.png",
            "JsonRPCAction": {
                "method": "run",
                "parameters": [keyword],
                "dontHideAfterAction": False
            }
        }]
        return results

    def run(self, keyword):
        with open('./setting.json', 'r') as r:
            setting = json.load(r)
        r.close()
        accountInf = [setting[key] for key in setting][2:]
        if "" in accountInf:
            os.popen('notepad {}\\\\setting.json'.format(os.getcwd()))
        else:
            screenShot()
            bdOCR(keyword, accountInf)


if __name__ == '__main__':
    Main()
